<?php

namespace app\adminapi\controller\v1\office;

use app\adminapi\controller\AuthController;
use app\services\office\OfficeChapterService;
use think\facade\App;

class OfficeChapter extends AuthController
{

    public function __construct(App $app,OfficeChapterService $service)
    {
        parent::__construct($app);
        $this ->services = $service;
    }

    public function index()
    {
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['class_id', ''],
            ['website_id', $this->website],
        ]);
        return app()->make('json')->successful($this->services->index($where));
    }

    public function createOrUpdate(){
        $where = $this->request->postMore([
            ['id', ''],
            ['pid', 0],
            ['class_id', ''],
            ['weight', ''],
            ['status', ''],
            ['title', ''],
            ['url', ''],
            ['website_id', $this->website],
        ]);
        return app()->make('json')->successful($this->services->createOrUpdate($where));
    }

    public function delete(){
        $where = $this->request->postMore([
            ['id', ''],
        ]);
        return app()->make('json')->successful($this->services->delete($where));
    }


    public function getList(){
        $where = $this->request->postMore([
            ['class_id',''],
            ['page', 1],
            ['pageSize', 20],
            ['website_id',$this  -> website],
        ]);
        return app() -> make('json') -> successful($this -> services -> getList($where));
    }

    public function getPidList(){
        $where = $this->request->postMore([
            ['class_id',''],
            ['website_id',$this  -> website],
        ]);
        return app() -> make('json') -> successful($this -> services -> getPidList($where));
    }


}